package com.content.view.Component.Button
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;

	public class HighLightToggleButton extends HighLightButton
	{
		private var _isToggle:Boolean = false;
		
		public function HighLightToggleButton(normalObj:DisplayObject, highLightObj:DisplayObject)
		{
			super(normalObj, highLightObj);
		}
		
		protected override function addEventListeners():void
		{
			addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
			addEventListener(MouseEvent.CLICK, onMouseClick);
		}
		
		// Events
		private function onMouseClick(evt:MouseEvent):void{
			_isToggle = !_isToggle;
			update();
		}
		
		private function update():void{
			if(_isToggle){
				MovieClip(_normalObj).gotoAndStop(2);
				MovieClip(_highLightObj).gotoAndStop(2);
			}else{
				MovieClip(_normalObj).gotoAndStop(1);
				MovieClip(_highLightObj).gotoAndStop(1);
			}
		}
		
		// Get and Set
		public function get isToggle():Boolean				{		return _isToggle;		}
		public function set isToggle(value:Boolean):void{
			_isToggle = value;
			update();
		}
		
		// public
		public override function Dispose():void{
			super.Dispose();
			removeEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			removeEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
			removeEventListener(MouseEvent.CLICK, onMouseClick);
		}
		
	}
}